using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Customer;
using System.Collections;

namespace WindowsFormsApplication1
{
    public partial class Bartender : Form
    {        
        Person person;
        BitArray status;
        string cardNumber;
        BeverageSizeSelect SizeSelect;

        public Bartender(Person Person, BitArray Status)
        {
            InitializeComponent();
            person = Person;
            status = Status;
            cardNumber = person.CardNumber;
            SizeSelect = new BeverageSizeSelect(Person, Status);
            
        }

        private void customersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.customersBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.userDatabaseDataSet);

        }

        private void Bartender_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'userDatabaseDataSet.Customers' table. You can move, or remove it, as needed.
            this.customersTableAdapter.Fill(this.userDatabaseDataSet.Customers);

        }

        private void Pour_Button_Click(object sender, EventArgs e)
        {
            StartAndStopPour startAndStop = new StartAndStopPour(person, status, SizeSelect);
            this.Close();
            startAndStop.ShowDialog();
        }

        private void CheckoutButton_Click(object sender, EventArgs e)
        {
            // Define file to write data to
            DateTime Date;
            Date = DateTime.Now;
            
            int day = Date.Day;
            int month = Date.Month;
            int year = Date.Year;

            
           string FullDate = month.ToString() + "_" + day.ToString() + "_" + year.ToString();

            string fileName = "C:\\Users\\eclark4\\Desktop\\DataBase\\" + FullDate +".txt";

               
            // Save data to fileName in XML format
            userDatabaseDataSet.WriteXml(fileName);
            userDatabaseDataSet.Dispose();


            // Delete all rows from table
            customersTableAdapter.ClearTable(); 

            // Update DataGridView
            customersTableAdapter.Fill(userDatabaseDataSet.Customers);
            this.Close();
            
        }


        private void Load_Click(object sender, EventArgs e)
        {
            /*int day = dateTimePicker1.Value.Day;
            int month = dateTimePicker1.Value.Month;
            int year = dateTimePicker1.Value.Year;

            string fileName = month.ToString() + "_" + day.ToString() + "_" + year.ToString() + ".txt";

            // Define file to write data to
            //string fileName = "C:\\Documents and Settings\\Alex\\Desktop\\" + textBox3.Text + ".txt";

            // Read data from fileName in XML format
            userDatabaseDataSet.ReadXml(fileName);

            // Update DataGridView on form
            //  customersTableAdapter.Fill(db_4_1DataSet.customers);
            */
        }

        private void customersBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
        {
            this.Validate();
            this.customersBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.userDatabaseDataSet);

        }

        private void Bartender_Load_1(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'userDatabaseDataSet.Customers' table. You can move, or remove it, as needed.
            this.customersTableAdapter.Fill(this.userDatabaseDataSet.Customers);

        }
    }
}
